/* import { useUserInfoStore } from '@/stores/userInfo'
import { getToken, removeToken } from '@/untils/token-untils'

//全局的前置守卫
router.beforeEach( async (to, form, next) => {
  const userInfoStore = useUserInfoStore()

  userInfoStore.$subscribe((mutation, state) => {
    console.log('userInfoStore updated:', state)
  })
  
  const token = getToken()
  const userInfo = !!userInfoStore.nickName
  if(token){
    //已经登录过，在进入登录页面，直接跳转到主页
    if(to.path == '/login'){
      next({path: "/"})
    }else{
      if(userInfo){
        //任何页面都能进
        next()
      }else{
        try{
          //没有nickName,第一次登录
          await userInfoStore.getInfo()
          next()
        }catch(error){
          //自带的token可以能有问题，我删除
          removeToken()
        }
      }
    }
  }else{
    //没有token,这是没有登录，直接放行
    next()
  }
})

export default router */